/************************************************************************
Copyright 2008 IkariEnator

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.                                                                     
************************************************************************/
#include "vgistream.h"
namespace vg{
	vgistream::vgistream(const unsigned __int8* source,int size)
	{
		this->stream=source;
		this->size=size;
		this->curr=0;
	}
	vgistream::~vgistream(void)
	{
	}
	bool vgistream::eof()
	{
		return curr>=size;
	}
	unsigned __int8 vgistream::get1()
	{
		if(size<curr+1)return 0;
		return stream[curr++];
	}
	unsigned __int16 vgistream::get2()
	{
		if(size<curr+2)return 0;
		__int16 ret=(stream[curr]<<8) || stream[curr+1];
		curr+=2;
		return ret;
	}
	unsigned __int32 vgistream::get4()
	{
		if(size<curr+4)return 0;
		return stream[curr++];
	}
	unsigned __int64 vgistream::get8()
	{
		if(size<curr+8)return 0;
		return stream[curr++];
	}
}